```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring组件注解详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            background-color: #f9f9f9;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
            color: white;
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .annotation-badge {
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
            letter-spacing: 0.5px;
        }
        .code-block {
            background-color: #f5f5f5;
            border-radius: 6px;
            padding: 16px;
            font-family: 'Courier New', Courier, monospace;
            font-size: 14px;
            border-left: 4px solid #6e8efb;
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 20px;
            font-size: 24px;
        }
        .footer {
            background-color: #1a1a1a;
            color: #e0e0e0;
        }
        .footer a:hover {
            color: #6e8efb;
        }
        .divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero py-20 px-4">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="serif text-4xl md:text-5xl font-bold mb-6">Spring组件注解详解</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8 mx-auto max-w-3xl">探索@Service、@Controller、@Component和@Repository的奥秘</p>
            <div class="flex justify-center space-x-4">
                <span class="annotation-badge bg-white text-purple-600">@Service</span>
                <span class="annotation-badge bg-white text-blue-600">@Controller</span>
                <span class="annotation-badge bg-white text-green-600">@Component</span>
                <span class="annotation-badge bg-white text-red-600">@Repository</span>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-xl p-8 card">
                <h2 class="serif text-3xl font-bold mb-6">Spring组件注解概述</h2>
                <p class="text-lg mb-6">在Spring框架中，组件注解是构建应用程序的基础。它们用于标识不同类型的组件，并让Spring容器能够自动发现和装配这些组件。</p>
                
                <div class="code-block mb-6">
                    <p>// Spring会自动扫描带有这些注解的类</p>
                    <p>// 并将它们创建为Bean，放入Spring容器中</p>
                    <p>@Component // 通用组件</p>
                    <p>@Service   // 服务层组件</p>
                    <p>@Controller // 控制器组件</p>
                    <p>@Repository // 数据访问组件</p>
                </div>
                
                <p class="text-gray-700">虽然这些注解在功能上相似，但它们具有不同的语义含义，有助于提高代码的可读性和可维护性。</p>
            </div>
        </section>

        <!-- Diagram Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl p-8 card">
                <h2 class="serif text-3xl font-bold mb-6">Spring组件架构关系</h2>
                <div class="mermaid">
                    graph TD
                        A[Spring容器] --> B[@Component]
                        B --> C[@Service]
                        B --> D[@Controller]
                        B --> E[@Repository]
                        C -->|业务逻辑| F[服务层]
                        D -->|处理请求| G[控制器层]
                        E -->|数据访问| H[持久层]
                </div>
                <p class="mt-6 text-gray-600 text-center">Spring组件注解的继承关系及其在应用架构中的位置</p>
            </div>
        </section>

        <!-- Detailed Explanation -->
        <section class="mb-16">
            <h2 class="serif text-3xl font-bold mb-8 text-center">各注解详细解析</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- @Component Card -->
                <div class="bg-white rounded-xl p-8 card">
                    <div class="feature-icon bg-green-100 text-green-600">
                        <i class="fas fa-puzzle-piece"></i>
                    </div>
                    <h3 class="serif text-2xl font-bold mb-4">@Component</h3>
                    <p class="mb-4">最通用的组件注解，用于标识任何Spring管理的组件。</p>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>适用于任何普通Java类</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>工具类、辅助类等通用组件</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>其他专用注解的基注解</span>
                        </li>
                    </ul>
                    <div class="code-block">
                        <p>@Component</p>
                        <p>public class ExampleComponent {</p>
                        <p>    // 组件实现</p>
                        <p>}</p>
                    </div>
                </div>
                
                <!-- @Service Card -->
                <div class="bg-white rounded-xl p-8 card">
                    <div class="feature-icon bg-purple-100 text-purple-600">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <h3 class="serif text-2xl font-bold mb-4">@Service</h3>
                    <p class="mb-4">专为业务逻辑层设计的组件注解。</p>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check text-purple-500 mt-1 mr-2"></i>
                            <span>标识业务逻辑组件</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-purple-500 mt-1 mr-2"></i>
                            <span>提高代码可读性和组织性</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-purple-500 mt-1 mr-2"></i>
                            <span>功能上与@Component相同</span>
                        </li>
                    </ul>
                    <div class="code-block">
                        <p>@Service</p>
                        <p>public class UserService {</p>
                        <p>    // 业务逻辑实现</p>
                        <p>}</p>
                    </div>
                </div>
                
                <!-- @Controller Card -->
                <div class="bg-white rounded-xl p-8 card">
                    <div class="feature-icon bg-blue-100 text-blue-600">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="serif text-2xl font-bold mb-4">@Controller</h3>
                    <p class="mb-4">Spring MVC中的控制器组件注解。</p>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check text-blue-500 mt-1 mr-2"></i>
                            <span>处理HTTP请求并返回响应</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-blue-500 mt-1 mr-2"></i>
                            <span>通常与@RequestMapping等注解配合使用</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-blue-500 mt-1 mr-2"></i>
                            <span>返回视图或数据给前端</span>
                        </li>
                    </ul>
                    <div class="code-block">
                        <p>@Controller</p>
                        <p>public class UserController {</p>
                        <p>    @GetMapping("/users")</p>
                        <p>    public String listUsers(Model model) {</p>
                        <p>        // 控制器逻辑</p>
                        <p>    }</p>
                        <p>}</p>
                    </div>
                </div>
                
                <!-- @Repository Card -->
                <div class="bg-white rounded-xl p-8 card">
                    <div class="feature-icon bg-red-100 text-red-600">
                        <i class="fas fa-database"></i>
                    </div>
                    <h3 class="serif text-2xl font-bold mb-4">@Repository</h3>
                    <p class="mb-4">数据访问层组件的专用注解。</p>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <i class="fas fa-check text-red-500 mt-1 mr-2"></i>
                            <span>标识数据访问组件(DAO)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-red-500 mt-1 mr-2"></i>
                            <span>自动转换数据库异常为Spring异常</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-red-500 mt-1 mr-2"></i>
                            <span>与JPA/Hibernate等ORM框架配合使用</span>
                        </li>
                    </ul>
                    <div class="code-block">
                        <p>@Repository</p>
                        <p>public class UserRepository {</p>
                        <p>    // 数据访问逻辑</p>
                        <p>}</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Best Practices -->
        <section class="mb-16">
            <div class="bg-white rounded-xl p-8 card">
                <h2 class="serif text-3xl font-bold mb-6">最佳实践与使用建议</h2>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-blue-600">如何选择正确的注解</h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">建议</span>
                                <span>根据组件职责选择最具体的注解</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">建议</span>
                                <span>避免滥用@Component，优先考虑专用注解</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">建议</span>
                                <span>保持层次结构清晰：Repository → Service → Controller</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-purple-600">常见误区与陷阱</h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">注意</span>
                                <span>所有注解功能相同，区别在于语义</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">注意</span>
                                <span>确保组件扫描配置正确</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">注意</span>
                                <span>避免循环依赖问题</span>
                            </li>
                        </ul>
                    </div>
                </div>
                
                <div class="mt-8 p-6 bg-gray-50 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4 text-green-600">实际项目中的分层示例</h3>
                    <div class="mermaid">
                        graph LR
                            A[Controller] -->|调用| B[Service]
                            B -->|调用| C[Repository]
                            C -->|访问| D[(Database)]
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Table -->
        <section class="mb-16">
            <div class="bg-white rounded-xl overflow-hidden card">
                <h2 class="serif text-3xl font-bold p-8 pb-4">Spring组件注解对比</h2>
                <div class="overflow-x-auto">
                    <table class="w-full">
                        <thead class="bg-gray-50">
                            <tr>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">注解</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">用途</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">适用层级</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">特殊功能</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-200">
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-green-600">@Component</td>
                                <td class="px-6 py-4">通用组件</td>
                                <td class="px-6 py-4">任意</td>
                                <td class="px-6 py-4">无</td>
                            </tr>
                            <tr class="bg-gray-50">
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-purple-600">@Service</td>
                                <td class="px-6 py-4">业务逻辑</td>
                                <td class="px-6 py-4">服务层</td>
                                <td class="px-6 py-4">提高可读性</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-blue-600">@Controller</td>
                                <td class="px-6 py-4">处理请求</td>
                                <td class="px-6 py-4">控制层</td>
                                <td class="px-6 py-4">处理HTTP请求</td>
                            </tr>
                            <tr class="bg-gray-50">
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-red-600">@Repository</td>
                                <td class="px-6 py-4">数据访问</td>
                                <td class="px-6 py-4">持久层</td>
                                <td class="px-6 py-4">异常转换</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>

        <!-- Additional Resources -->
        <section>
            <div class="bg-white rounded-xl p-8 card">
                <h2 class="serif text-3xl font-bold mb-6">延伸学习资源</h2>
                <div class="grid md:grid-cols-3 gap-6">
                    <a href="https://www.yuque.com/diantostring/ep2g5u/tl9au2tyy1xehgad" target="_blank" class="group">
                        <div class="border border-gray-200 rounded-lg p-6 hover:border-blue-400 transition-colors">
                            <h3 class="text-lg font-semibold mb-2 group-hover:text-blue-600">Spring常用注解有哪些</h3>
                            <p class="text-gray-600 text-sm">进一步了解Spring框架中的各种注解及其用途</p>
                        </div>
                    </a>
                    <a href="https://spring.io/" target="_blank" class="group">
                        <div class="border border-gray-200 rounded-lg p-6 hover:border-green-400 transition-colors">
                            <h3 class="text-lg font-semibold mb-2 group-hover:text-green-600">Spring官方文档</h3>
                            <p class="text-gray-600 text-sm">权威的Spring框架参考文档</p>
                        </div>
                    </a>
                    <a href="https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-stereotype-annotations" target="_blank" class="group">
                        <div class="border border-gray-200 rounded-lg p-6 hover:border-purple-400 transition-colors">
                            <h3 class="text-lg font-semibold mb-2 group-hover:text-purple-600">组件注解官方说明</h3>
                            <p class="text-gray-600 text-sm">Spring官方对组件注解的详细说明</p>
                        </div>
                    </a>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="footer py-12">
        <div class="container mx-auto max-w-5xl px-4 text-center">
            <div class="divider my-6"></div>
            <h3 class="text-xl font-medium mb-2">技术小馆</h3>
            <p class="mb-4">探索技术之美，分享知识之趣</p>
            <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors">http://www.yuque.com/jtostring</a>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```